package cz.proks.easyhelpdesk.gwt.event;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

import cz.proks.easyhelpdesk.api.model.Helpdesk;

public class HelpdeskChangeEvent extends GwtEvent<HelpdeskChangeEvent.Handler> {
    
    public final static Type<Handler> TYPE = new Type<HelpdeskChangeEvent.Handler>();
    
    public static interface Handler extends EventHandler {
        void onHelpdeskChange(HelpdeskChangeEvent event);
    }
    
    private final Helpdesk helpdesk;
    
    public HelpdeskChangeEvent(Helpdesk helpdesk) {        
        this.helpdesk = helpdesk;
    }
    
    public static void fireEvent(HasHelpdeskChangeHandlers source, Helpdesk helpdesk) {
        source.fireEvent(new HelpdeskChangeEvent(helpdesk));
    }
    
    public Helpdesk getHelpdesk() {
        return helpdesk;
    }

    @Override
    public Type<Handler> getAssociatedType() {
        return TYPE;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onHelpdeskChange(this);
    }
}
